﻿// Copyright (c) Vitaly Kamiansky. All rights reserved. 
// See License.txt in the project root.

using System;

namespace Property.Sequences
{
    public class DelegateSequenceConveyorDecorator<T> : SequenceConveyorDecorator<T>
    {
        public DelegateSequenceConveyorDecorator(ISequenceConveyor<T> compositionBaseConveyor, Func<IObservable<T>, IObservable<T>> modification)
            : base(compositionBaseConveyor)
        {
            if (modification == null) throw new ArgumentNullException("modification");

            _Modification = modification;
        }

        //=//

        private readonly Func<IObservable<T>, IObservable<T>> _Modification;

        public override IObservable<T> Create(Func<T> getValue)
        {
            return _Modification(_CompositionBaseConveyor.Create(getValue));
        }
    }
}
